#include "cpu/exec/template-start.h"
#include "cpu/decode/modrm.h"

#define instr push

static void do_execute(){
    if(DATA_BYTE == 2){
        cpu.esp -= DATA_BYTE;
        swaddr_write(cpu.esp, DATA_BYTE, op_src->val);
    }
    else{
        cpu.esp -= 4;
        swaddr_write(cpu.esp, 4, op_src->val);
    }
    print_asm_template1();
}
// static void do_execute() {
//         if (DATA_BYTE == 1) op_src->val = (int8_t)op_src->val;
//         reg_l(R_SP) -= 4;                       //为了pop方便，统一-4
//         swaddr_write(reg_l(R_SP), 4, (DATA_TYPE_S)op_src->val);
//         print_asm_template1();
// }

#if DATA_BYTE == 2 || DATA_BYTE == 4
make_instr_helper(rm)
make_instr_helper(r)

// make_helper(concat(push_m_, SUFFIX)){
//     op_dest->type = DATA_BYTE;
//     op_src->type = DATA_BYTE;
//     int len = read_ModR_M(eip + 1, op_dest, op_src);
//     assert(op_src->reg == 6);
//     cpu.esp -= DATA_BYTE;
//     swaddr_wirte(cpu.esp, DATA_BYTE, op_dest->val);
// //    print_asm("push" str(SUFFIX) " %s" op_dest->str);
//     return 1 + len;
// }

#endif



make_instr_helper(i)

#include "cpu/exec/template-end.h"